package com.xxx.modules.controller;;
import com.xxx.modules.service.BrandService;
import com.xxx.modules.entity.Brand;
import com.xxx.modules.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import com.xxx.modules.utils.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
 * 品牌
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-03-30
 */
@RestController
@RequestMapping("/common/brand")
@Api(tags="品牌")
public class BrandController {
    @Autowired
    private BrandService brandService;

    /**
    *  获取所有品牌
    * @param pageNum
    * @param pageSize
    * @param brand
    * @return
    */

    @GetMapping("/getBrandList")
    @ApiOperation("获取所有品牌")
    public Result getBrandList(Brand brand, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        return brandService.selectBrandList(brand,pageNum,pageSize);
    }


    @GetMapping("/getBrandInfo")
    @ApiOperation("根据id获取单个品牌")
    public Result getBrandInfo(Integer id){
        return brandService.selectBrandInfo(id);
    }

    /**
    * 保存品牌
    * @param brand
    * @return
    */
    @PostMapping("/saveBrandInfo")
    @ApiOperation("保存品牌")
    public Result saveBrandInfo(@RequestBody Brand brand){
        return brandService.saveBrandInfo(brand);
    }


    /**
     * 更新品牌
     * @param brand
     * @return
     */

    @PutMapping("/updateBrandInfo")
    @ApiOperation("更新品牌")
    public Result updateBrandInfo(@RequestBody Brand brand){
        return brandService.updateBrandInfo(brand);
    }

    /**
     * 根据id删除品牌
     * @param id
     * @return
     */
    @DeleteMapping("/delBrandInfo")
    @ApiOperation("根据id删除品牌")
    public Result delBrandInfo(Integer id){
        return brandService.delBrandInfo(id);
    }

    /**
     * 根据id集合批量删除品牌
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchBrandInfo")
    @ApiOperation("根据id集合批量删除品牌")
    public Result delBatchBrandInfo(String idList){
        return brandService.delBatchBrandInfo(idList);
    }










}